package com.ming.rabbitmq.two;

import com.ming.rabbitmq.util.RabbitMqUtils;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

public class Worker01 {
    public static final String QUEUE_NAME = "hello";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();

        DeliverCallback deliverCallback = (consumerTag, message) -> {

            System.out.println(new String(message.getBody()));

        };

        CancelCallback cancelCallback = consumerTag -> {
            System.out.println("消息消费被取消");
        };
        System.out.println("C2Worker正在等待接收消息：");

        channel.basicConsume(QUEUE_NAME, true, deliverCallback, cancelCallback);

    }
}
